<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('index')}">项目列表</a></li>
			<li class="active"><a href="">编辑</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('edit')}">
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label"><span class="form-required">*</span>项目名称</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-name" required name="name" value="{$result.name}">
				</div>
			</div>
			<div class="form-group">
				<label for="select-type" class="col-sm-2 control-label"><span class="form-required">*</span>项目类型</label>
				<div class="col-md-6 col-sm-10">
					<select name="type" id="select-type" class="form-control" required disabled>
						<switch name="result.type">
							<case value="1"><option value="1">开发对接市场</option></case>
							<case value="2"><option value="2">市场对接开发</option></case>
						</switch>
					</select>
				</div>
			</div>
			<div id="tab">
				<div class="form-group">
					<label for="input-pid" class="col-sm-2 control-label"><span class="form-required">*</span>产品选择</label>
					<div class="col-md-6 col-sm-10">
						<input class="form-control" type="text" value="{$result.info.name}" name="pname" disabled readonly id="input-pid"/>
					</div>
				</div>
				<div class="form-group">
					<label for="input-firaides" class="col-sm-2 control-label">开发助手</label>
					<div class="col-md-6 col-sm-10">
						<input class="form-control" type="text" style="width:400px;"  value="{$result.ouser.names|default=''}"
							   placeholder="请选择项目开发助手" onclick="doSelectLayer(this);"
							   data-url="{:url('user/check',['type' => 2])}" data-id="input-firaides" name="layer_temp[2]"
							   readonly/>
						<input class="form-control" type="hidden" value="{$result.ouser.ids|default=''}" name="firaides"
							   id="input-firaides"/>
					</div>
				</div>
				<div class="form-group">
					<label for="input-otherser" class="col-sm-2 control-label"><span class="form-required">*</span>市场人员</label>
					<div class="col-md-6 col-sm-10">
						<input class="form-control" type="text" style="width:400px;" required value="{$result.puser.names}"
							   placeholder="请选择市场人员" onclick="doSelectLayer(this);"
							   data-url="{:url('user/select',['type' => 3])}" data-id="input-otherser" name="layer_temp[3]"
							   readonly/>
						<input class="form-control" type="hidden" value="{$result.puser.ids}" name="otherser"
							   id="input-otherser"/>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label for="input-finances" class="col-sm-2 control-label"><span class="form-required">*</span>财务</label>
				<div class="col-md-6 col-sm-10">
					<input class="form-control" type="text" style="width:400px;" required value="{$result.cwuser.names}"
						   placeholder="请选择项目财务" onclick="doSelectLayer(this);"
						   data-url="{:url('user/select',['type' => 4])}" data-id="input-finances" name="layer_temp[4]"
						   readonly/>
					<input class="form-control" type="hidden" value="{$result.cwuser.ids}" name="finances"
						   id="input-finances"/>
				</div>
			</div>
			<div class="form-group">
				<label for="input-riskmanagements" class="col-sm-2 control-label"><span class="form-required">*</span>风控</label>
				<div class="col-md-6 col-sm-10">
					<input class="form-control" type="text" style="width:400px;" required value="{$result.fkuser.names}"
						   placeholder="请选择项目风控" onclick="doSelectLayer(this);"
						   data-url="{:url('user/select',['type' => 5])}" data-id="input-riskmanagements" name="layer_temp[5]"
						   readonly/>
					<input class="form-control" type="hidden" value="{$result.fkuser.ids}" name="riskmanagements"
						   id="input-riskmanagements"/>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="hidden" name="id" value="{$result.id}"/>
					<button type="submit" class="btn btn-primary js-ajax-submit">保存</button>
					<a class="btn btn-default" href="{:url('index')}">返回</a>
				</div>
			</div>
		</form>
	</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
	$(function(){
        $.selectType = function(type){
            switch(type) {
                case "1":
                    $('#tab').html($('#tab').html().replace('买家选择','产品选择'));
                    $('#tab').html($('#tab').html().replace('项目买家','项目产品'));
                    $('#tab').html($('#tab').html().replace('市场助手','开发助手'));
                    $('#tab').html($('#tab').html().replace('开发人员','市场人员'));
                    $('#tab').html($('#tab').html().replace('开发人员','市场人员'));
                    $('#p_select').attr('data-url',"{:url('resource_library/product_select')}");
                    $('input[name="layer_temp[2]"]').attr('data-url',"{:url('user/check',['type' => 2])}");
                    $('input[name="layer_temp[3]"]').attr('data-url',"{:url('user/select',['type' => 3])}");
                    break;
                case "2":
                    $('#tab').html($('#tab').html().replace('产品选择','买家选择'));
                    $('#tab').html($('#tab').html().replace('项目产品','项目买家'));
                    $('#tab').html($('#tab').html().replace('开发助手','市场助手'));
                    $('#tab').html($('#tab').html().replace('市场人员','开发人员'));
                    $('#tab').html($('#tab').html().replace('市场人员','开发人员'));
                    $('#p_select').attr('data-url',"{:url('buyer/buyer_select')}");
                    $('input[name="layer_temp[2]"]').attr('data-url',"{:url('user/check',['type' => 3])}");
                    $('input[name="layer_temp[3]"]').attr('data-url',"{:url('user/select',['type' => 2])}");
                    break;
            }
		}
        $.selectType($('#select-type').val());
	    $('#select-type').change(function(){
            $.selectType($(this).val());
		});
	});
</script>
</body>
</html>